package ru.inse.core.dao.realty.impl;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import ru.inse.core.domain.realty.RealtyItem;
import ru.inse.core.domain.realty.RealtyObject;
import ru.inse.core.domain.realty.RealtyRubric;


public class RealtyItemMapper
    implements RowMapper<RealtyItem>
{
    @Override
    public RealtyItem mapRow(ResultSet rs, int rowNum)
        throws SQLException
    {
        RealtyItem item = new RealtyItem();
        item.setId(rs.getLong("id"));
        item.setCdate(rs.getDate("cdate"));
        item.setUdate(rs.getDate("udate"));
        item.setArea(rs.getInt("area"));
        item.setPrice(rs.getInt("price"));
        item.setRubric(RealtyRubric.getByCode(rs.getLong("rubric_id")));
        item.setObject(RealtyObject.getById(rs.getLong("object_id")));
        //TODO заполнить остальные поля
        return item;
    }
}
